﻿#ifndef DAYITEM_H
#define DAYITEM_H
#include <QFrame>
#include <QLabel>
#include <QMouseEvent>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonValue>
#include <QStyleOption>
#include <QPainter>

enum DayState
{
    NORMAL = 0,     //正常
    JIABAN,     //加班
    XIUXI       //休息
};

enum DayPos
{
    PRE_MONTH = 0,  //上个月
    CUR_MONTH,      //当月
    NXT_MONTH       //下月
};

class DayItem : public QWidget
{
    Q_OBJECT

public:
    explicit DayItem(QWidget* parent = 0);

    void setSelected(bool isSelected);
    //void setIsToday(bool isToday);
    void setDayData(int day, QString cnDay);
    void setDayState(DayState state = NORMAL/*加班或则休息*/, bool isWeekend = false/*是否周末*/,
                     DayPos bInMonth = CUR_MONTH/*是否在本月的日期*/, bool isHoliday = false/*是否节日*/,
                     bool isToday = false/*是否当天*/);

    bool parse(QByteArray data);

    DayPos getInMonth(){return m_bInMonth;}
    bool getIsSelected(){return m_isSelected;}

    void Init();

    int getDay() {return m_day;}

protected:
    void mouseReleaseEvent(QMouseEvent* event);
    void paintEvent(QPaintEvent *e);

signals:
    void myClicked(DayItem* item);

private:
    bool m_isSelected;
    DayPos m_bInMonth;

    QLabel* m_jiaban;
    QLabel* m_xiuxi;

    QLabel* m_dayLabel;  //阳历日期
    QLabel* m_lunarLabel;   //阴历日期

    //假日
    QString m_holidy;
    //忌
    QString m_avoid;
    //属相
    QString m_animalsYear;
    //假日描述
    QString m_desc;
    //周几
    QString m_weekday;
    //宜
    QString m_suit;
    //纪年
    QString m_lunarYear;
    //农历
    QString m_lunar;
    //阳历
    int m_day;
};

#endif // DAYITEM_H
